﻿using System;
using DapperExtensions.Mapper;
using Newtonsoft.Json;
using ZilLion.Service.Core.Domain.EntityBase.JsonConverter;

namespace ZilLion.Service.WeChatMall.Domain.Entitys.Orders
{
    #region 配送信息

    public class OrderDeliverySendDto
    {
        /// <summary>
        ///     订单单据流水号ddlsh
        /// </summary>
        [JsonProperty("ordersno")]
        public string OrderSno { get; set; }

        /// <summary>
        ///     收货时间ddjfsj
        /// </summary>
        [JsonProperty("deliverytime")]
        [JsonConverter(typeof(ChinaDateTimeConverter))]
        public DateTime DeliveryTime { get; set; }

        /// <summary>
        ///     交付辅助信息：收货人性别：1-男，2-女ddshrxb
        /// </summary>
        [JsonProperty("sex")]
        public short Sex { get; set; }

        /// <summary>
        ///     交付辅助信息：经度,纬度ddjwd
        /// </summary>
        [JsonProperty("Location")]
        public string Location { get; set; }

        /// <summary>
        ///     交付辅助信息：城市code(该市身份证前缀) ddcscode
        /// </summary>
        [JsonProperty("adcode")]
        public string Adcode { get; set; }


        /// <summary>
        ///     交付辅助信息：地标地址（地图定位地址）dddbdz
        /// </summary>
        [JsonProperty("gpsaddress")]
        public string GpsAddress { get; set; }

        /// <summary>
        ///     交付辅助信息：送货地址(用户手输的详细地址)ddshr
        /// </summary>
        [JsonProperty("detailaddress")]
        public string DetailAddress { get; set; }


        /// <summary>
        ///     交付辅助信息：收货人ddshr
        /// </summary>
        [JsonProperty("receiver")]
        public string Receiver { get; set; }

        /// <summary>
        ///     交付辅助信息：收货人电话ddshrdh
        /// </summary>
        [JsonProperty("receivertel")]
        public string ReceiverTel { get; set; }

        /// <summary>
        ///     交付辅助信息：备注ddbz
        /// </summary>
        [JsonProperty("receiverdesc")]
        public string ReceiverDesc { get; set; }
    }

    /// <summary>
    ///     配送信息-正式
    /// </summary>
    public class OrderDeliverySendEntity : OrderDeliverySendDto
    {
    }

    /// <summary>
    ///     配送信息-待支付(暂存)
    /// </summary>
    public class PrePayOrderDeliverySendEntity : OrderDeliverySendDto
    {
    }

    public class OrderDeliverySendEntityMapper : ClassMapper<OrderDeliverySendEntity>
    {
        public OrderDeliverySendEntityMapper()
        {
            Table("weiscddjfxxpst");
            Map(f => f.OrderSno).Column("ddlsh").Key(KeyType.Assigned);
            Map(f => f.DeliveryTime).Column("ddjfsj");
            Map(f => f.Sex).Column("ddshrxb");
            Map(f => f.Location).Column("ddjwd");
            Map(f => f.Adcode).Column("ddcscode");
            Map(f => f.GpsAddress).Column("dddbdz");
            Map(f => f.DetailAddress).Column("ddshdz");
            Map(f => f.Receiver).Column("ddshr");
            Map(f => f.ReceiverTel).Column("ddshrdh");
            Map(f => f.ReceiverDesc).Column("ddbz");
        }
    }

    public class PrePayOrderDeliverySendEntityMapper : ClassMapper<PrePayOrderDeliverySendEntity>
    {
        public PrePayOrderDeliverySendEntityMapper()
        {
            Table("weiscdzfddjfxxpst");
            Map(f => f.OrderSno).Column("ddlsh").Key(KeyType.Assigned);
            Map(f => f.DeliveryTime).Column("ddjfsj");
            Map(f => f.Sex).Column("ddshrxb");
            Map(f => f.Location).Column("ddjwd");
            Map(f => f.Adcode).Column("ddcscode");
            Map(f => f.GpsAddress).Column("dddbdz");
            Map(f => f.DetailAddress).Column("ddshdz");
            Map(f => f.Receiver).Column("ddshr");
            Map(f => f.ReceiverTel).Column("ddshrdh");
            Map(f => f.ReceiverDesc).Column("ddbz");
        }
    }

    #endregion


    #region 自提信息

    public class OrderDeliverySinceDto
    {
        /// <summary>
        ///     订单单据流水号ddlsh
        /// </summary>
        [JsonProperty("ordersno")]
        public string OrderSno { get; set; }

        /// <summary>
        ///     交付机构id(允许=0)ddjfjgid
        /// </summary>
        [JsonProperty("sincebrid")]
        public long SinceBrid { get; set; }

        /// <summary>
        ///     交付机构
        /// </summary>
        [JsonProperty("sincebrname")]
        public string SinceBrName { get; set; }

        /// <summary>
        ///     交付日期ddjfsj
        /// </summary>
        [JsonProperty("sincetime")]
        [JsonConverter(typeof(ChinaDateTimeConverter))]
        public DateTime SinceTime { get; set; }

        /// <summary>
        ///     交付辅助信息：收货人性别：1-男，2-女ddshrxb
        /// </summary>
        [JsonProperty("sex")]
        public short Sex { get; set; }

        /// <summary>
        ///     交付辅助信息：收货人ddshr
        /// </summary>
        [JsonProperty("receiver")]
        public string Receiver { get; set; }

        /// <summary>
        ///     交付辅助信息：收货人电话ddshrdh
        /// </summary>
        [JsonProperty("receivertel")]
        public string ReceiverTel { get; set; }

        /// <summary>
        ///     交付辅助信息：备注ddbz
        /// </summary>
        [JsonProperty("receiverdesc")]
        public string ReceiverDesc { get; set; }
    }

    /// <summary>
    ///     自提信息
    /// </summary>
    public class OrderDeliverySinceEntity : OrderDeliverySinceDto
    {
    }

    /// <summary>
    ///     自提信息--未支付(暂存)
    /// </summary>
    public class PrePayOrderDeliverySinceEntity : OrderDeliverySinceDto
    {
    }

    public class OrderDeliverySinceEntityMapper : ClassMapper<OrderDeliverySinceEntity>
    {
        public OrderDeliverySinceEntityMapper()
        {
            Table("weiscddjfxxt");
            Map(f => f.OrderSno).Column("ddlsh").Key(KeyType.Assigned);
            Map(f => f.SinceBrid).Column("ddjfjgid");
            Map(f => f.SinceBrName).Column("ddjfjgname");
            Map(f => f.SinceTime).Column("ddjfsj");
            Map(f => f.Sex).Column("ddshrxb");
            Map(f => f.Receiver).Column("ddshr");
            Map(f => f.ReceiverTel).Column("ddshrdh");
            Map(f => f.ReceiverDesc).Column("ddbz");
        }
    }

    public class PrePayOrderDeliverySinceEntityMapper : ClassMapper<PrePayOrderDeliverySinceEntity>
    {
        public PrePayOrderDeliverySinceEntityMapper()
        {
            Table("weiscdzfddjfxxt");
            Map(f => f.OrderSno).Column("ddlsh").Key(KeyType.Assigned);
            Map(f => f.SinceBrid).Column("ddjfjgid");
            Map(f => f.SinceBrName).Column("ddjfjgname");
            Map(f => f.SinceTime).Column("ddjfsj");
            Map(f => f.Sex).Column("ddshrxb");
            Map(f => f.Receiver).Column("ddshr");
            Map(f => f.ReceiverTel).Column("ddshrdh");
            Map(f => f.ReceiverDesc).Column("ddbz");
        }
    }

    #endregion
}